<?php

namespace app_supplier\controllers;

use Yii;
use app_supplier\helpers\PurchaseHelper;
use yii\web\Controller;
use yii\helpers\Url;

class MainController extends BaseController
{
    public function actionIndex()
    {
        //获取配件求购信息

        $this->params['page']['pageSize']= 5;
        $list = PurchaseHelper::getList($this->params);
        $this->view->title = '系统主页';
        return $this->render('index', [
            'items'=>$list['list'],
            'num'=>PurchaseHelper::getCount()
        ]);
    }
//    public function beforeAction($action)
//    {
//
//        if (Yii::$app->user->isGuest) {
//            return $this->redirect('user/login');
//        }
//        $sort = Yii::$app->request->get('sort', 'create_time');
//        $order = Yii::$app->request->get('order', 'desc');
//        $this->params = [
//            'sort'=>[
//                $sort=>$order
//            ],
//            'page'=>[
//                'page'=>Yii::$app->request->get('page', 1),
//                'pageSize'=>!empty(Yii::$app->params['pageSize']) ? Yii::$app->params['pageSize'] : 50,
//                'url'=>Url::to([$this->id . '/'.$this->action->id]),
//            ],
//            'order'=>$order,
//            'sortField'=>$sort
//        ];
//        var_dump($this->params);exit;
//        return parent::beforeAction($action);
//    }
}